package learnjava.basic.javaIO.BIO;

import learnjava.basic.javaIO.BIO.Client;
import learnjava.basic.javaIO.BIO.Server;

import java.net.UnknownHostException;

public class TestNetWork {

    public static void main(String[] args) throws UnknownHostException {

        //1,获取本机ip地址和主机名
//        InetAddress i = InetAddress.getLocalHost();
//        System.out.println(i.toString());

        //2,获取任意主机的InetAddress
//        InetAddress ia = InetAddress.getByName("www.baidu.com");
//        System.out.println("address:"+ia.getHostAddress());
//        System.out.println("name:"+ia.getHostName());

        //3,一个域名可对应多台主机
//        InetAddress[] ias = InetAddress.getAllByName("www.bilibili.com");
//        for (InetAddress ia: ias) {
//            System.out.println(ia.getHostAddress());
//        }    //182.61.200.6  182.61.200.7

        //4,测试客户端服务器通信
//        Server s = new Server(8899);
//        Client c1 = new Client("localhost",8899,"1");
//        Client c2 = new Client("localhost",8899,"2");
//        s.start();
//        c1.start();
//        c2.start();
    }

}

